package com.iscreen.dbupgrade.operations;

import java.util.ArrayList;
import java.util.List;

import com.iscreen.dbupgrade.objects.Step;
import com.iscreen.utils.constants.Constants;
import com.iscreen.utils.db.connection.DBConnection;
import com.iscreen.utils.exceptions.IScreenException;

public class UpgradeStep extends UpgradeOperation
{

	private final long id;
	private final String description;
	private final List<UpgradeCommand> upgradeCommands = new ArrayList<UpgradeCommand>();
//	private final StepBuilder builder;

	public UpgradeStep(DBConnection connection, Step step)
	{
		this.connection = connection;
		this.id = step.getId();
		this.description = step.getDescription();
		
	}

//	public UpgradeStep(DBConnection connection, long id, String description,
//			StepBuilder builder)
//	{
//		this.connection = connection;
//		this.id = id;
//		this.description = description;
//		this.builder = builder;
//	}

	public void addCommand(UpgradeCommand command)
	{
		upgradeCommands.add(command);
	}

	@Override
	protected void doExecute() throws IScreenException
	{
		for (UpgradeCommand upgradeCommand : upgradeCommands)
		{
			upgradeCommand.execute();
		}

	}

	@Override
	public long getCommandId()
	{
		return 0;
	}

	@Override
	public long getStepId()
	{
		return id;
	}

	@Override
	public String getOperation()
	{
		return description;
	}

	@Override
	public String getSql()
	{
		return Constants.STR_EMPTY;
	}

	public void build()
	{
//		builder.build(this);
	}

}
